package com.boomsecret.cas;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by wangjinliang on 2018/4/26.
 */
public class CASDemo {
    private static AtomicInteger count = new AtomicInteger(0);

    public static void main(String[] args) {
        for (int i = 0; i < 2; i ++) {
            new Thread(() -> {
                try {
                    Thread.sleep(10);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                for (int index = 0; index < 100; index ++) {
                    count.incrementAndGet();
                }
            }).start();
        }
        try {
            Thread.sleep(1000);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(count);
    }
}
